package com.ruoyi.project.system.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.domain.SysLocation;
import com.ruoyi.project.system.service.ISysLocationService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 收货地址Controller
 *
 * @author theme
 * @date 2021-01-20
 */
@Api(description = "收货地址Controller" )
@RestController
@RequestMapping("/system/location" )
public class SysLocationController extends BaseController {
    @Autowired
    private ISysLocationService sysLocationService;

/**
 * 查询收货地址列表
 */
@ApiOperation("查询收货地址列表" )
@PreAuthorize("@ss.hasPermi('system:location:list')" )
@GetMapping("/list" )
        public TableDataInfo list(SysLocation sysLocation) {
        startPage();
        List<SysLocation> list = sysLocationService.selectSysLocationList(sysLocation);
        return getDataTable(list);
    }
    
   /* *//**
     * 获取收货地址详细信息
     *//*
    @ApiOperation("获取收货地址详细信息" )
    @PreAuthorize("@ss.hasPermi('system:location:query')" )
    @GetMapping(value = "/{id}" )
    public AjaxResult getInfo(@PathVariable("id" ) Long id) {
        return AjaxResult.success(sysLocationService.selectSysLocationById(id));
    }*/

    /**
     * 新增收货地址
     */
    @ApiOperation("新增收货地址" )
    @PreAuthorize("@ss.hasPermi('system:location:add')" )
    @Log(title = "收货地址" , businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysLocation sysLocation) {
        return toAjax(sysLocationService.insertSysLocation(sysLocation));
    }

    /**
     * 修改收货地址
     */
    @ApiOperation("修改收货地址" )
    @PreAuthorize("@ss.hasPermi('system:location:edit')" )
    @Log(title = "收货地址" , businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysLocation sysLocation) {
        return toAjax(sysLocationService.updateSysLocation(sysLocation));
    }

    /**
     * 删除收货地址
     */
    @ApiOperation("删除收货地址" )
    @PreAuthorize("@ss.hasPermi('system:location:remove')" )
    @Log(title = "收货地址" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}" )
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(sysLocationService.deleteSysLocationByIds(ids));
    }
}
